<?php

/**
 * This is the model class for table "alumni".
 *
 * The followings are the available columns in table 'alumni':
 * @property integer $alumni_id
 * @property string $alumni_code
 * @property string $alumni_registration_date
 * @property string $alumni_company_name
 * @property string $alumni_company_contact_num
 * @property string $company_address
 * @property string $alumni_occupation
 * @property integer $alumni_people_id
 *
 * The followings are the available model relations:
 * @property People $alumniPeople
 */
class Alumni extends CActiveRecord
{
	/**
	 * Returns the static model of the specified AR class.
	 * @param string $className active record class name.
	 * @return Alumni the static model class
	 */
	  public function getAlumniName()
	{
		return $this->alumniPeople->alumniName;
	}
	
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return 'alumni';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('alumni_code, alumni_registration_date, alumni_people_id', 'required'),
			array('alumni_people_id', 'numerical', 'integerOnly'=>true),
			array('alumni_code, alumni_company_name, company_address', 'length', 'max'=>45),
			array('alumni_company_contact_num', 'length', 'max'=>7),
			array('alumni_occupation', 'length', 'max'=>100),
			// The following rule is used by search().
			// Please remove those attributes that should not be searched.
			array('alumni_id, alumni_code, alumni_registration_date, alumni_company_name, alumni_company_contact_num, company_address, alumni_occupation, alumni_people_id', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
			'alumniPeople' => array(self::BELONGS_TO, 'People', 'alumni_people_id'),
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'alumni_id' => 'Alumni',
			'alumni_code' => 'Alumni Code',
			'alumni_registration_date' => 'Registration Date',
			'alumni_company_name' => 'Company Name',
			'alumni_company_contact_num' => 'Company Contact Num',
			'company_address' => 'Address',
			'alumni_occupation' => 'Occupation',
			'alumni_people_id' => 'Alumni People',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
	 */
	public function search()
	{
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('alumni_id',$this->alumni_id);
		$criteria->compare('alumni_code',$this->alumni_code,true);
		$criteria->compare('alumni_registration_date',$this->alumni_registration_date,true);
		$criteria->compare('alumni_company_name',$this->alumni_company_name,true);
		$criteria->compare('alumni_company_contact_num',$this->alumni_company_contact_num,true);
		$criteria->compare('company_address',$this->company_address,true);
		$criteria->compare('alumni_occupation',$this->alumni_occupation,true);
		$criteria->compare('alumni_people_id',$this->alumni_people_id);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}
}